package java_oop_chapter3;
/**
 * a system that you could add student, delete student, show number of students 
 */
import java.util.Arrays;
import java.util.Scanner;

public class StudentManagement {
	Scanner in = new Scanner(System.in);
	Students[] stu = new Students[0];
	int i=-1;
	
	public void showAll() {
		for(int i=0;i<stu.length;i++) {
			System.out.printf("%s\t%d",stu[i].stuName,stu[i].age);
			System.out.println();
		}
	}
		public void addStu(Students s) {
		System.out.print("input name:");
		s.stuName = in.next();
		System.out.print("input age:");
		s.age = in.nextInt();
		stu = Arrays.copyOf(stu,stu.length+1);
    	i++;
		stu[i] = s;
		
	
		} 
		
		public void delStu(String name) {
			for(int i=0;i<stu.length;i++) {
				if(stu[i].stuName.equals(name)) {
					stu[i] = stu[stu.length-1];
					stu = Arrays.copyOf(stu, stu.length-1);
				}
			}

		}
		
		//show student number
		public void showNumber() {
		System.out.println(stu.length);
	}
	
	
}
